<?php
namespace app\api\controller;

use think\Controller;
use app\common\model\User as UserModel;

class Base extends Controller
{
	public $user;

	public function initialize()
	{
		$token = cookie('token');
		if($token){
			$this->user = UserModel::token($token)->find();
			if(!$this->user){
				$ip = request()->ip();
				$num = cache($ip);
				$num = $num ? ($num + 1) : 1;
				if($num > 15){
					cache($ip,$num,$num);
					die(cdm(500,0,'超速访问!请等待'.$num.'秒后继续访问!'));
				}
				cache($ip,$num,1);
			}
		}
	}
}